<template>
  <div>
    <bread></bread>
    <el-card>
      <el-form :inline="true">
        <el-form-item>
          <el-input placeholder="请输入搜索内容" clearable>
            <!-- 搜索按钮 -->
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">添加用户</el-button>
        </el-form-item>
      </el-form>
      <!-- 表格区 -->
      <el-table :data="goodlist" style="width: 100%" border stripe>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column label="商品名称" prop="good_name"></el-table-column>
        <el-table-column label="商品价格" prop="good_price"></el-table-column>
        <el-table-column label="商品重量" prop="good_weight"></el-table-column>
        <el-table-column label="创建时间" prop="add_time"></el-table-column>
        <el-table-column label="操作"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
import bread from "../Bread";
export default {
  components: {
    bread
  },
  data() {
    return {
      queryInfo: {
        query: "",
        pagenum: "1",
        pagesize: "3"
      },
      total: 0,
      //   商品列表
      goodlist: []
    };
  },
  created() {
    this.getGoodList();
  },
  methods: {
    async getGoodList() {
      const { data: res } = await this.$http.get("goods", {
        params: this.queryInfo
      });
      if (res.meta.status !== 200) {
        return this.$message.error("获取商品列表失败");
      }
      this.$message.success("获取商品列表成功");
      this.goodlist = res.data.goods;
      this.total = res.data.total;
    }
  }
};
</script>
<style lang="">
</style>